<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>每日签到 - 龙虎斗</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            background-attachment: fixed;
            min-height: 100vh;
            color: #333;
            transition: background 0.3s ease;
        }

        /* 主题颜色样式 */
        body.theme-blue {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-green {
            background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-orange {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-purple {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-pink {
            background: linear-gradient(135deg, #fa709a 0%, #fee140 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-red {
            background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-yellow {
            background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-cyan {
            background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-lime {
            background: linear-gradient(135deg, #d299c2 0%, #fef9d7 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-indigo {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-teal {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-rose {
            background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-amber {
            background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-emerald {
            background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-sky {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%) !important;
            background-attachment: fixed !important;
        }

        body.theme-violet {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
            background-attachment: fixed !important;
        }

        .container {
            max-width: 480px;
            margin: 0 auto;
            background: transparent;
            min-height: 100vh;
            position: relative;
        }

        .header {
            background: rgba(102, 126, 234, 0.9);
            backdrop-filter: blur(10px);
            color: white;
            padding: 20px;
            text-align: center;
            position: relative;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }

        .back-btn {
            position: absolute;
            left: 20px;
            top: 50%;
            transform: translateY(-50%);
            background: rgba(255, 255, 255, 0.2);
            border: none;
            color: white;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            font-size: 18px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(10px);
        }

        .header h1 {
            font-size: 20px;
            font-weight: 600;
            margin: 0;
        }

        .checkin-content {
            padding: 20px;
        }

        /* 签到状态卡片 */
        .status-card {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
            color: white;
            border-radius: 20px;
            padding: 25px;
            margin-bottom: 20px;
            text-align: center;
            box-shadow: 0 8px 25px rgba(40, 167, 69, 0.3);
            position: relative;
            overflow: hidden;
        }

        .status-card.completed {
            background: linear-gradient(135deg, #6c757d 0%, #adb5bd 100%);
        }

        .status-card::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
            animation: float 6s ease-in-out infinite;
        }

        @keyframes float {
            0%, 100% { transform: translateY(0px) rotate(0deg); }
            50% { transform: translateY(-20px) rotate(180deg); }
        }

        .status-icon {
            font-size: 48px;
            margin-bottom: 15px;
        }

        .status-title {
            font-size: 24px;
            font-weight: 700;
            margin-bottom: 10px;
        }

        .status-desc {
            font-size: 16px;
            opacity: 0.9;
            margin-bottom: 20px;
        }

        .checkin-btn {
            background: rgba(255, 255, 255, 0.2);
            border: 2px solid rgba(255, 255, 255, 0.3);
            color: white;
            padding: 15px 30px;
            border-radius: 25px;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
        }

        .checkin-btn:hover:not(:disabled) {
            background: rgba(255, 255, 255, 0.3);
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
        }

        .checkin-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .checkin-btn.completed {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.2);
        }

        /* 签到统计 */
        .stats-section {
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            border-radius: 18px;
            padding: 25px;
            margin-bottom: 20px;
            border: 1px solid rgba(233, 236, 239, 0.8);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        .stats-title {
            color: #495057;
            font-size: 18px;
            margin-bottom: 20px;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 12px;
            padding-bottom: 12px;
            border-bottom: 2px solid #e9ecef;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 15px;
        }

        .stat-item {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            border-radius: 15px;
            text-align: center;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
            transition: transform 0.3s ease;
        }

        .stat-item:hover {
            transform: translateY(-5px);
        }

        .stat-value {
            font-size: 24px;
            font-weight: 700;
            margin-bottom: 8px;
        }

        .stat-label {
            font-size: 14px;
            opacity: 0.9;
        }

        /* 签到日历 */
        .calendar-section {
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            border-radius: 18px;
            padding: 25px;
            margin-bottom: 20px;
            border: 1px solid rgba(233, 236, 239, 0.8);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        .calendar-title {
            color: #495057;
            font-size: 18px;
            margin-bottom: 20px;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 12px;
            padding-bottom: 12px;
            border-bottom: 2px solid #e9ecef;
        }

        .calendar-grid {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 8px;
        }

        .calendar-day {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .calendar-day.weekday {
            background: rgba(102, 126, 234, 0.1);
            color: #667eea;
        }

        .calendar-day.today {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
            color: white;
            transform: scale(1.1);
            box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
        }

        .calendar-day.checked {
            background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
            color: #8b6914;
        }

        .calendar-day.future {
            background: rgba(233, 236, 239, 0.5);
            color: #adb5bd;
        }

        /* 奖励展示 */
        .rewards-section {
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            border-radius: 18px;
            padding: 25px;
            margin-bottom: 20px;
            border: 1px solid rgba(233, 236, 239, 0.8);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        .rewards-title {
            color: #495057;
            font-size: 18px;
            margin-bottom: 20px;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 12px;
            padding-bottom: 12px;
            border-bottom: 2px solid #e9ecef;
        }

        .rewards-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 15px;
        }

        .reward-item {
            text-align: center;
            padding: 20px 15px;
            border-radius: 15px;
            background: rgba(248, 249, 250, 0.8);
            transition: all 0.3s ease;
            border: 2px solid rgba(233, 236, 239, 0.6);
            position: relative;
        }

        .reward-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
        }

        .reward-item.available {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
            color: white;
            border-color: #28a745;
        }

        .reward-item.claimed {
            background: rgba(233, 236, 239, 0.5);
            color: #6c757d;
            border-color: #adb5bd;
        }

        .reward-icon {
            font-size: 32px;
            margin-bottom: 10px;
        }

        .reward-name {
            font-weight: 600;
            margin-bottom: 5px;
            font-size: 14px;
        }

        .reward-desc {
            font-size: 11px;
            opacity: 0.8;
            line-height: 1.3;
        }

        .reward-item.available .reward-desc {
            opacity: 0.9;
        }

        /* 签到记录 */
        .history-section {
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            border-radius: 18px;
            padding: 25px;
            margin-bottom: 20px;
            border: 1px solid rgba(233, 236, 239, 0.8);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        .history-title {
            color: #495057;
            font-size: 18px;
            margin-bottom: 20px;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 12px;
            padding-bottom: 12px;
            border-bottom: 2px solid #e9ecef;
        }

        .history-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .history-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px;
            background: rgba(248, 249, 250, 0.8);
            border-radius: 10px;
            border-left: 4px solid #28a745;
        }

        .history-icon {
            font-size: 18px;
            color: #28a745;
        }

        .history-content {
            flex: 1;
        }

        .history-text {
            font-size: 14px;
            color: #495057;
            margin-bottom: 4px;
        }

        .history-time {
            font-size: 12px;
            color: #6c757d;
        }

        /* 响应式设计 */
        @media (max-width: 480px) {
            .stats-grid {
                grid-template-columns: 1fr;
                gap: 12px;
            }

            .rewards-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 12px;
            }

            .calendar-grid {
                gap: 6px;
            }

            .calendar-day {
                font-size: 12px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <button class="back-btn" onclick="goBack()">←</button>
            <h1>每日签到</h1>
        </div>

        <div class="checkin-content">
            <!-- 签到状态卡片 -->
            <div class="status-card" id="statusCard">
                <div class="status-icon" id="statusIcon">🎁</div>
                <div class="status-title" id="statusTitle">今日未签到</div>
                <div class="status-desc" id="statusDesc">点击下方按钮完成今日签到，获得丰厚奖励！</div>
                <button class="checkin-btn" id="checkinBtn" onclick="performCheckin()">
                    立即签到
                </button>
            </div>

            <!-- 签到统计 -->
            <div class="stats-section">
                <h3 class="stats-title">
                    <span>📊</span>
                    签到统计
                </h3>
                <div class="stats-grid">
                    <div class="stat-item">
                        <div class="stat-value" id="totalCheckins">156</div>
                        <div class="stat-label">总签到天数</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-value" id="currentStreak">5</div>
                        <div class="stat-label">连续签到</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-value" id="maxStreak">28</div>
                        <div class="stat-label">最长连续</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-value" id="monthlyCheckins">22</div>
                        <div class="stat-label">本月签到</div>
                    </div>
                </div>
            </div>

            <!-- 签到日历 -->
            <div class="calendar-section">
                <h3 class="stats-title">
                    <span>📅</span>
                    本月签到日历
                </h3>
                <div class="calendar-grid" id="calendarGrid">
                    <!-- 日历将通过JavaScript动态生成 -->
                </div>
            </div>

            <!-- 奖励展示 -->
            <div class="rewards-section">
                <h3 class="stats-title">
                    <span>🎁</span>
                    签到奖励
                </h3>
                <div class="rewards-grid">
                    <div class="reward-item available">
                        <div class="reward-icon">💰</div>
                        <div class="reward-name">金币奖励</div>
                        <div class="reward-desc">每日签到获得50金币</div>
                    </div>
                    <div class="reward-item available">
                        <div class="reward-icon">⭐</div>
                        <div class="reward-name">经验奖励</div>
                        <div class="reward-desc">每日签到获得20经验</div>
                    </div>
                    <div class="reward-item claimed">
                        <div class="reward-icon">🎯</div>
                        <div class="reward-name">连续奖励</div>
                        <div class="reward-desc">连续7天额外奖励</div>
                    </div>
                    <div class="reward-item">
                        <div class="reward-icon">🏆</div>
                        <div class="reward-name">月度奖励</div>
                        <div class="reward-desc">满月签到特殊奖励</div>
                    </div>
                    <div class="reward-item">
                        <div class="reward-icon">💎</div>
                        <div class="reward-name">稀有道具</div>
                        <div class="reward-desc">随机获得稀有道具</div>
                    </div>
                    <div class="reward-item">
                        <div class="reward-icon">🚀</div>
                        <div class="reward-name">加速道具</div>
                        <div class="reward-desc">游戏加速体验</div>
                    </div>
                </div>
            </div>

            <!-- 签到记录 -->
            <div class="history-section">
                <h3 class="stats-title">
                    <span>📝</span>
                    最近签到记录
                </h3>
                <div class="history-list" id="historyList">
                    <!-- 签到记录将通过JavaScript动态生成 -->
                </div>
            </div>
        </div>
    </div>

    <script>
        // 返回上一页
        function goBack() {
            window.history.back();
        }

        // 应用主题颜色
        function applyTheme(theme) {
            console.log('每日签到页面应用主题:', theme);
            
            // 移除所有主题类
            const body = document.body;
            const allThemes = ['theme-blue', 'theme-green', 'theme-orange', 'theme-purple', 
                              'theme-pink', 'theme-red', 'theme-yellow', 'theme-cyan', 
                              'theme-lime', 'theme-indigo', 'theme-teal', 'theme-rose', 
                              'theme-amber', 'theme-emerald', 'theme-sky', 'theme-violet'];
            
            allThemes.forEach(themeClass => {
                body.classList.remove(themeClass);
            });
            
            // 添加新主题类
            if (theme && theme !== 'default') {
                body.classList.add('theme-' + theme);
                console.log('已应用主题类:', 'theme-' + theme);
            }
        }

        // 检查并同步主题
        function checkAndSyncTheme() {
            const savedTheme = localStorage.getItem('selectedTheme');
            const lastUpdateTime = localStorage.getItem('themeUpdateTime');
            
            if (savedTheme && lastUpdateTime) {
                console.log('检测到保存的主题:', savedTheme);
                applyTheme(savedTheme);
            }
        }

        // 监听主题变化
        function startThemeListener() {
            let lastThemeUpdateTime = localStorage.getItem('themeUpdateTime') || '0';
            
            // 定期检查主题更新
            setInterval(() => {
                const currentThemeUpdateTime = localStorage.getItem('themeUpdateTime') || '0';
                
                if (currentThemeUpdateTime !== lastThemeUpdateTime) {
                    console.log('检测到主题更新');
                    lastThemeUpdateTime = currentThemeUpdateTime;
                    
                    const savedTheme = localStorage.getItem('selectedTheme');
                    if (savedTheme) {
                        console.log('同步新主题:', savedTheme);
                        applyTheme(savedTheme);
                    }
                }
            }, 500);
        }

        // 执行签到
        function performCheckin() {
            const checkinBtn = document.getElementById('checkinBtn');
            const statusCard = document.getElementById('statusCard');
            const statusIcon = document.getElementById('statusIcon');
            const statusTitle = document.getElementById('statusTitle');
            const statusDesc = document.getElementById('statusDesc');
            
            // 检查是否已经签到
            if (checkinBtn.classList.contains('completed')) {
                alert('今日已签到，明天再来吧！');
                return;
            }

            // 执行签到
            checkinBtn.classList.add('completed');
            checkinBtn.textContent = '已签到';
            checkinBtn.disabled = true;
            
            // 更新状态卡片
            statusCard.classList.add('completed');
            statusIcon.textContent = '✅';
            statusTitle.textContent = '今日已签到';
            statusDesc.textContent = '恭喜您完成今日签到！获得金币和经验奖励！';
            
            // 更新统计数据
            updateCheckinStats();
            
            // 更新日历
            updateCalendar();
            
            // 更新签到记录
            updateHistory();
            
            // 显示签到成功提示
            showCheckinSuccess();
            
            // 保存签到状态到本地存储
            const today = new Date().toDateString();
            localStorage.setItem('lastCheckin', today);
            
            // 更新签到总数
            const currentTotal = parseInt(document.getElementById('totalCheckins').textContent);
            document.getElementById('totalCheckins').textContent = currentTotal + 1;
            
            // 更新连续签到天数
            const currentStreak = parseInt(document.getElementById('currentStreak').textContent);
            document.getElementById('currentStreak').textContent = currentStreak + 1;
        }

        // 显示签到成功提示
        function showCheckinSuccess() {
            // 创建成功提示元素
            const notification = document.createElement('div');
            notification.style.cssText = `
                position: fixed;
                top: 20px;
                right: 20px;
                background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
                color: white;
                padding: 15px 20px;
                border-radius: 10px;
                box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
                z-index: 10000;
                font-size: 14px;
                font-weight: 500;
                transform: translateX(100%);
                transition: transform 0.3s ease;
            `;
            notification.textContent = '🎉 签到成功！获得50金币和20经验！';
            
            // 添加到页面
            document.body.appendChild(notification);
            
            // 显示提示
            setTimeout(() => {
                notification.style.transform = 'translateX(0)';
            }, 100);
            
            // 3秒后自动隐藏
            setTimeout(() => {
                notification.style.transform = 'translateX(100%)';
                setTimeout(() => {
                    document.body.removeChild(notification);
                }, 300);
            }, 3000);
        }

        // 更新签到统计
        function updateCheckinStats() {
            // 这里可以添加更多统计逻辑
            console.log('签到统计已更新');
        }

        // 生成日历
        function generateCalendar() {
            const calendarGrid = document.getElementById('calendarGrid');
            const today = new Date();
            const currentMonth = today.getMonth();
            const currentYear = today.getFullYear();
            const daysInMonth = new Date(currentYear, currentMonth + 1, 0).getDate();
            const firstDayOfMonth = new Date(currentYear, currentMonth, 1).getDay();
            
            // 清空日历
            calendarGrid.innerHTML = '';
            
            // 添加星期标题
            const weekdays = ['日', '一', '二', '三', '四', '五', '六'];
            weekdays.forEach(day => {
                const dayElement = document.createElement('div');
                dayElement.className = 'calendar-day weekday';
                dayElement.textContent = day;
                calendarGrid.appendChild(dayElement);
            });
            
            // 添加空白天数
            for (let i = 0; i < firstDayOfMonth; i++) {
                const emptyDay = document.createElement('div');
                emptyDay.className = 'calendar-day';
                calendarGrid.appendChild(emptyDay);
            }
            
            // 添加月份天数
            for (let day = 1; day <= daysInMonth; day++) {
                const dayElement = document.createElement('div');
                dayElement.className = 'calendar-day';
                dayElement.textContent = day;
                
                // 标记今天
                if (day === today.getDate()) {
                    dayElement.classList.add('today');
                }
                
                // 标记已签到的日期（模拟数据）
                if (day <= today.getDate() && Math.random() > 0.3) {
                    dayElement.classList.add('checked');
                }
                
                // 标记未来日期
                if (day > today.getDate()) {
                    dayElement.classList.add('future');
                }
                
                calendarGrid.appendChild(dayElement);
            }
        }

        // 更新日历
        function updateCalendar() {
            generateCalendar();
        }

        // 生成签到记录
        function generateHistory() {
            const historyList = document.getElementById('historyList');
            const mockHistory = [
                { text: '今日签到成功', time: '刚刚' },
                { text: '昨日签到成功', time: '昨天' },
                { text: '前日签到成功', time: '2天前' },
                { text: '连续签到7天', time: '3天前' },
                { text: '获得月度奖励', time: '1周前' }
            ];
            
            historyList.innerHTML = '';
            
            mockHistory.forEach(record => {
                const historyItem = document.createElement('div');
                historyItem.className = 'history-item';
                historyItem.innerHTML = `
                    <div class="history-icon">✅</div>
                    <div class="history-content">
                        <div class="history-text">${record.text}</div>
                        <div class="history-time">${record.time}</div>
                    </div>
                `;
                historyList.appendChild(historyItem);
            });
        }

        // 更新签到记录
        function updateHistory() {
            generateHistory();
        }

        // 检查今日签到状态
        function checkTodayCheckin() {
            const today = new Date().toDateString();
            const lastCheckin = localStorage.getItem('lastCheckin');
            
            if (lastCheckin === today) {
                // 今日已签到
                const checkinBtn = document.getElementById('checkinBtn');
                const statusCard = document.getElementById('statusCard');
                const statusIcon = document.getElementById('statusIcon');
                const statusTitle = document.getElementById('statusTitle');
                const statusDesc = document.getElementById('statusDesc');
                
                checkinBtn.classList.add('completed');
                checkinBtn.textContent = '已签到';
                checkinBtn.disabled = true;
                
                statusCard.classList.add('completed');
                statusIcon.textContent = '✅';
                statusTitle.textContent = '今日已签到';
                statusDesc.textContent = '恭喜您完成今日签到！获得金币和经验奖励！';
            }
        }

        // 页面加载时初始化
        document.addEventListener('DOMContentLoaded', function() {
            console.log('每日签到页面加载完成');
            
            // 检查并同步主题
            checkAndSyncTheme();
            
            // 启动主题监听器
            startThemeListener();
            
            // 监听页面可见性变化
            document.addEventListener('visibilitychange', function() {
                if (!document.hidden) {
                    console.log('页面变为可见，检查主题更新');
                    checkAndSyncTheme();
                }
            });
            
            // 检查今日签到状态
            checkTodayCheckin();
            
            // 生成日历
            generateCalendar();
            
            // 生成签到记录
            generateHistory();
            
            console.log('主题同步功能已启动');
            console.log('当前保存的主题:', localStorage.getItem('selectedTheme'));
            console.log('主题更新时间:', localStorage.getItem('themeUpdateTime'));
        });
    </script>
</body>
</html>
